package cn.tedu.oa.attendance.controller;

import cn.tedu.oa.attendance.base.response.JsonResult;
import cn.tedu.oa.attendance.pojo.dto.query.AttendanceQuery;
import cn.tedu.oa.attendance.pojo.entity.Attendance;
import cn.tedu.oa.attendance.pojo.po.AttendancePO;
import cn.tedu.oa.attendance.service.AttendanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("oa/attendance")
public class AttendanceController {

    @Autowired
    private AttendanceService attendanceService;

    @PostMapping("/add")
    public JsonResult addAttendance(@RequestBody AttendancePO attendancePO) {
        attendanceService.save(attendancePO);
        log.debug("添加考勤记录成功：{}",attendancePO);
        return JsonResult.ok();
    }

    @GetMapping("/list")
    public JsonResult listAttendances(AttendanceQuery query) {

        List<Attendance> list = attendanceService.getlist(query);

        return JsonResult.ok(list);
    }
}
